package com.kc.aivoiceapp.adapter

import com.kc.aivoiceapp.R
import com.kc.aivoiceapp.data.ChatList
import com.kc.aivoiceapp.entity.AppConstants
import com.kc.lib_base.base.adapter.CommonAdapter
import com.kc.lib_base.base.adapter.CommonViewHolder

/**
 *@ClassName ChatListAdapter
 *@author created by kingchao
 *@时间：2021/8/16 15:44
 *@note:对话列表适配器
 */
class ChatListAdapter(
        mList: List<ChatList>
) : CommonAdapter<ChatList>(mList, object : OnMoreBindDataListener<ChatList> {

    override fun onBindViewHolder(model: ChatList, viewHolder: CommonViewHolder, type: Int, position: Int) {

        when (type) {
            AppConstants.TYPE_MINE_TEXT -> viewHolder.setText(R.id.tv_mine_text, model.text)
            AppConstants.TYPE_AI_TEXT -> viewHolder.setText(R.id.tv_ai_text, model.text)
            AppConstants.TYPE_AI_WEATHER -> {
            }
        }

    }

    override fun getLayoutId(type: Int): Int {
        return when (type) {
            AppConstants.TYPE_MINE_TEXT -> R.layout.layout_mine_text
            AppConstants.TYPE_AI_TEXT -> R.layout.layout_ai_text
            AppConstants.TYPE_AI_WEATHER -> R.layout.layout_ai_weather
            else -> 0
        }
    }

    override fun getItemType(position: Int): Int {
        return mList[position].type
    }

})